package src.com.servlet;

import src.com.data.ClickCoordinate;
import src.com.service.MyService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class GetClickCoordinate extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        float x = Float.parseFloat(req.getParameter("x"));
        float y = Float.parseFloat(req.getParameter("y"));
        int  page_num = Integer.parseInt(req.getParameter("page_num"));
        //System.out.println(x+","+y+","+page_num);
        ClickCoordinate coordinate = new ClickCoordinate(x,y,page_num);
        MyService myService = new MyService();
        String result = myService.getClickWord(coordinate);
        PrintWriter out = resp.getWriter();
        out.print(result);
        out.flush();
        out.close();
    }
}
